﻿// libsvg.cpp : Defines the exported functions for the DLL.
//

#include "pch.h"
#include "framework.h"
#include "libsvg\libsvg.h"
#include "SvgFile.h"


// This is an example of an exported variable
//LIBSVG_API int nlibsvg=0;

//// This is an example of an exported function.
//LIBSVG_API int fnlibsvg(void)
//{
//    return 0;
//}

LIBSVG_API bool fDrawSvgToCDC(CString csSvgPath, CDC* pdc, CPoint ptStart)
{
	bool ret = true;
	ClibSvgService* pClibSvgService = new ClibSvgService();
	ret= pClibSvgService->DrawSvgToCDC(csSvgPath, pdc, ptStart);
	delete pClibSvgService;
	return ret;
}

LIBSVG_API bool fDrawSvgToCDC2(TCHAR* pSvgPath, CDC* pdc, CPoint ptStart)
{
	bool ret=true;
	if ((pSvgPath == NULL) || (pdc==NULL)) {
		return false;
	}
	CString mSvgPath(pSvgPath);
	ret = fDrawSvgToCDC(mSvgPath, pdc, ptStart);
	return ret;
}

// This is the constructor of a class that has been exported.
ClibSvgService::ClibSvgService()
{
    return;
}

bool ClibSvgService::DrawSvgToCDC(CString csSvgPath, CDC* pdc, CPoint ptStart)
{
	bool ret = true;
	CSvgFile* pSvgFile = new CSvgFile();
	ret= pSvgFile->LoadSvgFile(csSvgPath, pdc, ptStart);
	if (pSvgFile != NULL) {
		delete pSvgFile;
		pSvgFile = NULL;
	}
	return ret;
}
